package com.cy.pj.goods.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {
//    @ExceptionHandler(IllegalArgumentException.class)
//    @ResponseBody
//    public String doHandleException(IllegalArgumentException e){
//        log.error("illegalArgumentException.exception {}",e.getMessage());
//        return e.getMessage();
//    }
    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public JsonResult doHandleRuntimeException(RuntimeException e){
        log.error("RuntimeException.exception {}",e.getMessage());
        return new JsonResult(e);
    }
}
